package zero.tech.games.logic.work;

import zero.tech.core.work.QueueWork;
import zero.tech.core.work.WorkQueue;
import zero.tech.games.logic.common.Room;
import zero.tech.games.logic.data.RoomStatus;
import zero.tech.games.logic.util.LogicUtil;
import zero.tech.wsnet.controller.LogicController;

public class OfflineFromRoom extends QueueWork{
	private Room room;
	private LogicController logicController;
	@Override
	public void init(Object... objs) throws Exception {
		room=(Room) objs[0];
		logicController=(LogicController) objs[1];
	}

	@Override
	public void run() {
		int room_status=room.getRoom_status();
		if(room_status==RoomStatus.DEFAULT) {
			LogicUtil.freeRoomController(room,logicController,true);
		}else {
			LogicUtil.offlineRoomController(room,logicController);
		}
	}

	@Override
	public WorkQueue getWorkQueue() {
		return new WorkQueue() {
			@Override
			public long getId() {
				return room.getQueue_id();
			}
		};
	}

}
